import type { RouteRecordRaw } from 'vue-router';

export function getMenuList(router: RouteRecordRaw[]){
  const menuList: GlobalMenuOption[] = [];
  if(Array.isArray(router)){
    router.forEach((route) => {
      const menuItem = {
        key: route?.name,
        label: route?.meta?.title,
        routeName:route?.name,
        routePath:route?.path,
        icon: route?.meta?.icon
      } as GlobalMenuOption;

      if(route.children && route.children.length){
        menuItem.children =  getMenuList(route.children);
      }
      menuList.push(menuItem);
    });

  }
  return menuList;
}
